<?php

namespace Shahu\Common\exception;

use support\exception\BusinessException;
use Webman\Http\Request;
use Webman\Http\Response;
use function app\exception\json;

class FailException extends BusinessException
{
    /**
     * 转换异常为 HTTP 响应
     * @param Request $request
     * @return Response|null
     */
    public function render(Request $request): ?Response
    {
        return json([
            'code' => 10001,
            'message' => $this->getMessage(),
            'data' => []
        ]);
    }
}
